<!DOCTYPE html>
<html>
<head>
    <title>{% if task %}编辑任务{% else %}新建任务{% endif %}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input[type="text"], textarea {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        textarea {
            height: 100px;
        }
        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            text-decoration: none;
            display: inline-block;
        }
        .btn-primary {
            background-color: #007bff;
            color: white;
        }
        .btn-secondary {
            background-color: #6c757d;
            color: white;
        }
    </style>
</head>
<body>
    <h1>{% if task %}编辑任务{% else %}新建任务{% endif %}</h1>
    <form method="post">
        {% csrf_token %}
        <div class="form-group">
            <label for="title">标题：</label>
            <input type="text" id="title" name="title" value="{{ task.title|default:'' }}" required>
        </div>
        <div class="form-group">
            <label for="description">描述：</label>
            <textarea id="description" name="description">{{ task.description|default:'' }}</textarea>
        </div>
        {% if task %}
        <div class="form-group">
            <label>
                <input type="checkbox" name="completed" {% if task.completed %}checked{% endif %}>
                已完成
            </label>
        </div>
        {% endif %}
        <button type="submit" class="btn btn-primary">保存</button>
        <a href="{% url 'task_list' %}" class="btn btn-secondary">返回</a>
    </form>
</body>
</html> 